package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import io.renren.common.annotation.DataFilter;
import io.renren.common.utils.Constant;
import io.renren.modules.sys.dao.CarDispatchDao;
import io.renren.modules.sys.entity.CarDispatchEntity;
import io.renren.modules.sys.entity.OrdertrackingEntity;
import io.renren.modules.sys.service.CarDispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.ContainerDao;
import io.renren.modules.sys.entity.ContainerEntity;
import io.renren.modules.sys.service.ContainerService;


@Service("carDispatchService")
public class CarDispatchServiceImpl extends ServiceImpl<CarDispatchDao, CarDispatchEntity> implements CarDispatchService {
    @Autowired
    private CarDispatchServiceImpl carDispatchService;
    @Override
    @DataFilter(subDept = true, user = false)
    public PageUtils queryPage(Map<String, Object> params) {
        Page<CarDispatchEntity> page = this.selectPage(
                new Query<CarDispatchEntity>(params).getPage(),
                new EntityWrapper<CarDispatchEntity>()
                        .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
                        .like("car",params.get("car").toString()));
        int count = 0 ;
        Wrapper<CarDispatchEntity> wrapperUtil = new EntityWrapper<>();
        count = carDispatchService.selectCount(wrapperUtil
                .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER)).like("car",params.get("car").toString()));
        page.setTotal(count);
        return new PageUtils(page);
    }

}
